// tabs.js
Page({
  data: {
    currentList: [] // 当前显示的数据
  },
  onLoad: function () {
    // this.setData({
    //   currentList: this.data.list1
    // });
  },
  onShow: function () {
    this.getlsit()

  },
  getlsit: function () {
    wx.showLoading({
      title: '加载中',
    });
    const openId = wx.getStorageSync('openId');
    console.log(openId);
    // 调用云函数获取地址列表 
    wx.cloud.callFunction({
      name: 'xiaoBangCommonFunction',
      data: {
        getUserInfoRequest: {
          userId: openId
        }
      },
      success: res => {
        console.log('[云函数]', res.result.data.address)
        this.setData({
          currentList: res.result.data.address
        });
        wx.hideLoading();
      },
      fail: err => {
        console.error('[云函数] [xiaoBangCommonFunction] 调用失败', err)
      }
    })
  },
  onReachBottom: function () {
    // 模拟上拉加载更多数据
    // const newList = this.data.currentList.concat([...this.data.list1]); // 添加新数据
    // this.setData({
    //   currentList: newList
    // });
  },

  onPullDownRefresh: function () {
    // 模拟下拉刷新数据
    this.getlsit()
    wx.stopPullDownRefresh(); // 停止下拉刷新动画
  },
  curitemAdd: function (e) {
    console.log(e.currentTarget.dataset.item);
    wx.navigateTo({
      url: `/pages/addEditingAddress/index?option=${JSON.stringify(e.currentTarget.dataset.item)}`,
    });
  }
});